﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Tencent.OA.App
{
    /// <summary>
    /// 定义一个是否有权限访问SiteMapNode的接口。
    /// </summary>
    public interface ISiteMapNodeVisibilityProvider
    {
        /// <summary>
        /// 确定是否有权限访问指定的SiteMapNode节点。
        /// </summary>
        /// <param name="node">指定的SiteMapNode节点。</param>
        /// <param name="context">封装的当前 HTTP 请求的所有 HTTP 特定的信息。</param>
        /// <param name="sourceMetadata">The source metadata.</param>
        /// <returns>如果有权限访问该节点返回 <c>true</c>，否则返回 <c>false</c>。</returns>
        bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata);
    }

    /// <summary>
    /// ISiteMapNodeVisibilityProvider接口的默认实现。
    /// </summary>
    public class DefaultSiteMapNodeVisibilityProvider : ISiteMapNodeVisibilityProvider
    {
        /// <summary>
        /// Determines whether the node is visible.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="context">The context.</param>
        /// <param name="sourceMetadata">The source metadata.</param>
        /// <returns>始终返回true。</returns>
        public bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata)
        {
            return true;
        }
    }

}
